#include "Connection.hpp"
int main()
{
    mq::AsyncWorker::AsyncWorkerPtr work = make_shared<mq::AsyncWorker>();
    mq::Connection::ConnectionPtr conn = make_shared<mq::Connection>("127.0.0.1", 8088, work);
    conn->connect();
    mq::Channel::ChannelPtr cp = conn->openChannel();
    google::protobuf::Map<string, string> args;
    cp->declareExchange("exchange1", mq::ExchangeType::TOPIC, true, false, args);
    cp->declareQueue("queue1", true, false, false, args);
    cp->declareQueue("queue2", true, false, false, args);
    cp->queueBind("exchange1", "queue1", "queue1");
    cp->queueBind("exchange1", "queue2", "news.music.#");
    for (int i = 0; i < 5; ++i)
    {
        mq::BasicProperties bp1;
        bp1.set_id(to_string(i + 1));
        bp1.set_delivery_mode(mq::DeliveryMode::DURABLE);
        bp1.set_routing_key("news.sport");
        cp->basicPublish("exchange1", &bp1, "HelloWorld" + to_string(i + 1));
    }
    mq::BasicProperties bp2;
    bp2.set_id(to_string(10));
    bp2.set_delivery_mode(mq::DeliveryMode::DURABLE);
    bp2.set_routing_key("news.music.pop");
    cp->basicPublish("exchange1", &bp2, "HelloBite");
    conn->closeChannel(cp);
    return 0;
}